package mapred.config;

import mapred.util.Configuration;

public class AppConfig extends Configuration<String, String> {

    private static final String kvDelim = "=";
    
    private static final String entryDelim = " ";

    public AppConfig() {
        super("", kvDelim, entryDelim);
    }
    
    public AppConfig(String[] args) {
        this();
        this.set(args);
    }
    
    @Override
    protected String decodeKey(String strKey) {
        return normalizeKey(strKey);
    }

    @Override
    protected String decodeValue(String strValue) {
        return strValue;
    }

    @Override
    protected boolean isValidKey(String key) {
        return (key != null && !key.isEmpty());
    }

    @Override
    protected String mergeValue(String key, String oldV, String newV) {
        return newV;
    }
 
    public void set(String key, Object value) {
        this.set(key, value.toString());
    }

    @Override
    public String normalizeKey(String key) {
        return key.toLowerCase();
    }
    
    public void set(String... settings) {
        for (String s : settings) {
            this.add(s);
        }
    }
    
}
